{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1436
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
   i,n,j,ind,c:longint;
   a,b:array[0..1010] of longint;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
read(n);
for i:=1 to n do read(a[i]);
for i:=2 to n do begin
    ind:=i;
    for j:=1 to i-1 do
        if a[j]>a[i] then begin
           ind:=j;
           break;
        end;
    c:=1;
    for j:=1 to ind-1 do begin
        b[j]:=a[c];
        inc(c);
    end;
    b[ind]:=a[i];
    for j:=ind+1 to n do begin
        if c<>i then b[j]:=a[c] else begin
           inc(c);
           b[j]:=a[c];
        end;
        inc(c);
    end;
    a:=b;
    if ind<>i then begin
       for j:=1 to n do write(a[j],' ');
       writeln;
    end;
end;
end.